<?php include DIR_MODULES . 'menu/menu_main_pg_news.php'?>

<table cellpadding="0" cellspacing="0" width="960px" border="0" align="center">
    <tr>
        <td  id="coloana_dreapta_root_corp" valign="top">
        <!-- mijloc si dreapta //////////////////////////////////// -->
            <table cellpadding="0" cellspacing="0" width="100%" border="0">
                <tr>
                    <td id="content_corp" valign="top">
                    <!-- articole mijloc /////////////////////////////////////// -->
                        <div class="mijloc_root">
                            <?php
                                $data = mysql_query("select * from dt_pages where p_id = '11'");
                                while ($row = mysql_fetch_array($data)){
                                    $dquery = mysql_query("select * from dt_news");

                                    $total_items = mysql_num_rows($dquery);
                                    $limit = 6;
                                    $page = 1;

                                    if((!$limit)  || (is_numeric($limit) == false) || ($limit < 1) || ($limit > 50))
                                        $limit = 2; //default

                                    $total_pages = ceil($total_items/$limit);


                                    if($total_pages>0){
                                        echo '<div id="paginationdemo" class="demo">';
                                        for($i=1;$i<=$total_pages;$i++){
                                            $set_limit = $i * $limit - ($limit);

                                            if($i == 1){
                                                echo '<div id="p'.$i.'" class="pagedemo _current">';
                                                echo '<div class="mijloc_modul_corporate">';
                                                echo '<table class="mijloc_modul_corporate" cellpadding="0" cellspacing="0" border="0" width="100%">';

                                                $iquery = mysql_query("select * from dt_news order by news_date asc limit $set_limit,$limit");
                                                while ($drow = mysql_fetch_array($iquery)){
                                                    echo '<tr>';
                                                    echo '<td valign="top">';
                                                    echo '<div class="articol_corp_titlu"><a href="news/'.$drow['news_id'].'/'.cleanitup($drow['news_title']).'.html">'.$drow['news_title'].'</a></div>';
                                                    echo '<div class="articol_corp_text">';
                                                    echo '<a class="link_vaca" href="news/'.$drow['news_id'].'/'.cleanitup($drow['news_title']).'.html">'.limitclear($drow['news_content'], 300).'...</a>';
                                                    echo '</div>';
                                                    echo '<div class="corporate_postcontent"><b>'.$drow['news_date'].'</b></div>';
                                                    echo '</td>';
                                                    echo '<tr><td colspan="2"><div class="mijloc_hr" style="clear:both">&nbsp;</div></td></tr>';
                                                    echo '</tr>';
                                                }
                                                echo '</table>';
                                                echo '</div>';
                                                echo '</div>';
                                            } else {
                                                echo '<div id="p'.$i.'" class="pagedemo" style="display:none;">';
                                                echo '<div class="mijloc_modul_corporate">';
                                                echo '<table class="mijloc_modul_corporate" cellpadding="0" cellspacing="0" border="0" width="100%">';

                                                $iquery = mysql_query("select * from dt_news order by news_date asc limit $set_limit,$limit");
                                                while ($drow = mysql_fetch_array($iquery)){
                                                    echo '<tr>';
                                                    echo '<td valign="top">';
                                                    echo '<div class="articol_corp_titlu"><a href="news/'.$drow['news_id'].'/'.cleanitup($drow['news_title']).'.html">'.$drow['news_title'].'</a></div>';
                                                    echo '<div class="articol_corp_text">';
                                                    echo '<a href="news/'.$drow['news_id'].'/'.cleanitup($drow['news_title']).'.html">'.limitclear($drow['news_content'], 300).'...</a>';
                                                    echo '</div>';
                                                    echo '<div class="corporate_postcontent"><b>'.$drow['news_date'].'</b></div>';
                                                    echo '</td>';
                                                    echo '<tr><td colspan="2"><div class="mijloc_hr" style="clear:both">&nbsp;</div></td></tr>';
                                                    echo '</tr>';
                                                }
                                                echo '</table>';
                                                echo '</div>';
                                                echo '</div>';
                                            }
                                        }
                                        echo '<div id="demo5"></div>';
                                        echo '</div>';
                                    } else { echo 'Nu exista stiri.'; }
                                }
                            ?>
                            <script type="text/javascript">
                            $(function() {
                                $("#demo5").paginate({
                                    count                   : <?php echo $total_pages;?>,
                                    start                   : 1,
                                    display                 : 6,
                                    border                  : false,
                                    border_color            : '#fff',
                                    text_color              : '#00A5CF',
                                    background_color        : 'white',
                                    border_hover_color      : '#ccc',
                                    text_hover_color        : '#006699',
                                    background_hover_color  : '#fff',
                                    images                  : false,
                                    mouse                   : 'press',
                                    onChange                : function(page){
                                        $('._current','#paginationdemo').removeClass('_current').hide();
                                        $('#p'+page).addClass('_current').show();
                                  }
                                });
                            });
                            </script>
                        </div>
                    <!-- end articole mijloc /////////////////////////////////// -->
                    </td>
                    <td class="coloana_separator" valign="top">&nbsp;</td>
                    <?php
                        $cDreapta = mysql_query("select * from dt_mod_visible
                                        where z_id = '2'
                                        and visible = '1'
                                        and p_id = '11'
                                        order by `order`");
                        //daca nu exista nici un rezultat atunci ascunde coloana
                        if (mysql_num_rows($cDreapta)>0){
                    ?>
                    <td id="content_dreapta" valign="top">
    <!-- content dreapta ////////////////////////////////////// -->
                    <?php
                        include DIR_MODULES . 'coloane_module/coloana_dreapta.php';
                    ?>
    <!-- end content dreapta ////////////////////////////////// -->
                    </td>
                    <?php }?>
                </tr>
            </table>
        <!-- end mijloc si dreapta //////////////////////////////// -->
        </td>
    </tr>
</table>